const express = require('express');
const router = new express.Router();

/**
 * @param {Object} options
 * @param {} options.code 编号
 * @param {} options.name 名称
 * @param {} options.status 状态  1-生效  -1-注销
 * @throws {Error}
 * @return {Promise}
 */
router.get('/export', async(req, res, next) => {
    const options = {
        code: req.query.code,
        name: req.query.name,
        status: req.query.status
    };
    const data = {
        message: '导出成功',
        payload: 'Mock导出'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.dealerId 服务站Id(总代)
 * @param {} options.brandId 品牌Id
 * @param {} options.partCode 备件编号
 * @param {} options.localCode 地产件编号
 * @param {} options.partReplacementCode 替换件编号
 * @param {} options.status 状态
 * @param {} options.productCategoryCode 产品分类编号
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/', async(req, res, next) => {
    const options = {
        dealerId: req.query.dealerId,
        brandId: req.query.brandId,
        partCode: req.query.partCode,
        localCode: req.query.localCode,
        partReplacementCode: req.query.partReplacementCode,
        status: req.query.status,
        productCategoryCode: req.query.productCategoryCode,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id93',
                    brandCode: 'DAVZXFA',
                    dealerCode: 'Chery',
                    dealerName: '奇瑞',
                    localCode: 'localCode96',
                    localName: 'localName97',
                    minPackSize: 'minPackSize',
                    partReplacementCode: 'partReplacementCode1',
                    price: 132.00,
                    manufactory: '海外工厂',
                    status: 1,
                    currency: 1,
                    rowVersion: 'rowVersion',
                    options: [
                        'abandon'
                    ]
                },
                {
                    id: 'id94',
                    brandCode: 'DADASFDSA',
                    dealerCode: 'cFDAS',
                    dealerName: '奇瑞002',
                    localCode: 'localCode93',
                    localName: 'localName95',
                    minPackSize: 'minPackSize',
                    partReplacementCode: 'partReplacementCode2',
                    price: 124.01,
                    manufactory: '国内工厂',
                    status: 1,
                    currency: 1,
                    rowVersion: 'rowVersion',
                    options: [
                        'abandon'
                    ]
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id107',
            brandCode: 'brandCode',
            localCode: 'localCode110',
            localName: 'localName111',
            dealerCode: 'dealerCode112',
            dealerName: 'dealerName113',
            minPackSize: 'minPackSize',
            partReplacementCode: 'partReplacementCode',
            price: 1305.50,
            manufactory: '海外工厂',
            productCategoryCode: 'productCategoryCode',
            status: 1,
            remark: 'remark',
            currency: 1,
            rowVersion: 'rowVersion',
            options: [
                'abandon'
            ]
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/abandon', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @throws {Error}
 * @return {Promise}
 */
router.post('/import', async(req, res, next) => {
    const options = {
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
module.exports = router;
